yoshi matsu / EasyPlayback
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EasyPlayback.h Source File

EasyPlayback.h

00001 /* mbed EasyPlayback Library
00002  * Copyright (C) 2017 dkato
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef __EASY_PLAYBACK_H__
00018 #define __EASY_PLAYBACK_H__
00019 
00020 #include <string>
00021 #include <map>
00022 #include "EasyDecoder.h"
00023 #include "AUDIO_GRBoard.h"
00024 #include "AUDIO_RBSP.h"
00025 #include "FATFileSystem.h"
00026 
00027 class EasyPlayback
00028 {
00029 public:
00030     typedef enum {
00031         AUDIO_TPYE_SSIF,
00032         AUDIO_TPYE_SPDIF
00033     } audio_type_t;
00034 
00035     EasyPlayback(audio_type_t type = AUDIO_TPYE_SSIF);
00036     ~EasyPlayback();
00037     bool get_tag(const char* filename, char* p_title, char* p_artist, char* p_album, uint16_t tag_size);
00038     bool play(const char* filename);
00039     bool is_paused(void);
00040     void pause(void);
00041     void pause(bool type);
00042     void skip(void);
00043     bool outputVolume(float VolumeOut);
00044 
00045     template<typename T>
00046     void add_decoder(const string& extension) {
00047         m_lpDecoders[extension] = &T::inst;
00048     }
00049 
00050 private:
00051     #define AUDIO_WRITE_BUFF_NUM   (8)
00052     #define AUDIO_MSK_RING_BUFF    (AUDIO_WRITE_BUFF_NUM - 1)
00053     AUDIO_GRBoard * _audio_ssif;
00054     AUDIO_RBSP * _audio;
00055     int _buff_index;
00056     audio_type_t _type;
00057     bool _skip;
00058     bool _pause;
00059     bool _init_end;
00060     uint32_t _audio_buff_size;
00061     uint8_t *_heap_buf;
00062     uint8_t *_audio_buf;
00063     std::map<std::string, EasyDecoder*(*)()> m_lpDecoders;
00064 
00065     EasyDecoder * create_decoer_class(const char* filename);
00066 };
00067 
00068 #endif