Bonjour à tous,

Dans le cadre d'un projet Audio, j'ai été amené à développer une "petite" dll pour gérer une playlist. Sans être un habitué du C++ j'ai réussi à faire fonctionner le code ci-dessus. Mais le principal problème est que les caractères étendues ne sont pas pris en charge et lorsque l'on veut travailler avec des nom de fichiers audio c'est problématique.

Dans le code ci-dessous, si je remplace les char par des wchar_t, le compilateur détecte une erreur de type entre wchar_t et les std::string.
Je modifie les types std::string par des std::wstring puisse le compilateur m'indique un autre problème sur le nombre de paramètres sur la ligne de code :
std::getline( iss, L_Fichier_audio,';') (pour la fonction

En fait, je ne sais pas si :
1) je suis sur la bonne voix pour transformer mon code afin qu'il prenne en charge les caractères accentués
2) Une nouvelle syntaxe pour getline ou une autre instruction doit être utilisée ?
3) Y at'il des paramètres de compilateur à modifier ?

Bref, j'ai besoin de vos lumières.
Merci par avance de votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#include "stdafx.h"
#include "bass.h"
#include "bassmix.h"
#include <sstream> 
#include <string>  
#include <iostream>
#include <random>
#include <time.h>
//#include <wchar.h>

typedef struct {
       HSTREAM    G_Mixer;  //Mixer pour synchro playlist
       HSTREAM  G_Source;
       HANDLE G_Objet;
    } WD_BASS_PLAYLIST;
//WD_BASS_PLAYLIST str_retourne;

class Play_list {
    
private:
    
    

    // METHODE
    int rand_a_b(int a, int b);
    int* init_tableau(int a, int b);
    void melanger(int* tableau, int taille);
    std::string new_file_audio();
    static void CALLBACK SyncProc(HSYNC handle, DWORD channel, DWORD data, void *user);

    // ATTRIBUTS
    WD_BASS_PLAYLIST m_str_playlist;
    std::string m_liste_fichier_audio; // Liste des fichiers audio qui composent la Playlist.
    const char *m_PlayList;
    const int m_nombre_fichier_audio; // Nombre total de fichiers audio dans la play list.
    int* m_tab_playlist; // Tableau d'ordre de lecture de la playlist.
    int m_cpt_tab; // Position interne de parcours de la playlist.
    const bool m_lect_alea; // Flag pour forcer la lecture aléatoire Vrai = Lecture aléatoire - Faux = Lecture chronologique.
    DWORD m_mixer;
    DWORD m_source;

public:

    

    // METHODES
    Play_list(); // Constructeur par défaut
    Play_list(const char *m_PlayList, int nombre_fichier_audio, bool lect_alea); // Constructeur surchargé 4 paramètres
    ~Play_list(); // Destructeur
    //void Creer(DWORD P_HDMixer, DWORD P_Nb_File_audio, const char *P_PlayList, DWORD P_len_char, BOOL P_Lect_alea);
    WD_BASS_PLAYLIST* Creer();
    
};



//Constructeur par défaut
Play_list::lay_list() : m_PlayList(0), m_nombre_fichier_audio(0),m_lect_alea(false), m_cpt_tab(0), m_mixer(0), m_source(0)
{
}

// Constructeur avec paramètres
Play_list::lay_list(const char *PlayList, int nombre_fichier_audio, bool lect_alea) : m_PlayList(PlayList), m_nombre_fichier_audio(nombre_fichier_audio),m_lect_alea(lect_alea), m_cpt_tab(0), m_mixer(0), m_source(0)
{
}

// Destructeur
Play_list::~Play_list()
{
}

//FUNCTION RANDOM BORNEE
//----------------------
int Play_list::rand_a_b(int a, int b) {
    return rand()%(b-a) + a;
}

//FUNCTION REMPLIR TABLEAU
//------------------------
    int* Play_list::init_tableau(int a, int b) {
        int taille = b - a+1;
        int* resultat=(int*)malloc(taille*sizeof(int));
        
        srand(time(NULL));
        // On remplit le tableau chronologiguement
        for(int i=0;i<taille;i++){
        resultat[i]=i+a;
        }
    return resultat;
    }

//FUNCTION DE MELANGE DE TABLEAU
//------------------------------
void Play_list::melanger(int* tableau, int taille) {
    int i=0;
    int nombre_tire=0;
    int temp=0;
    for (i=0;i<taille;i++) {
        nombre_tire=this->rand_a_b(0,taille);
        temp = tableau[i];
        tableau[i] = tableau[nombre_tire];
        tableau[nombre_tire] = temp;
    }
}

// FUNCTION : Fournis un fichier Audio depuis la PlayList en fonction du tableau de distribution (aléatoire ou chrono)
//------------------------------------------------------------------------------------------------------------------
std::string Play_list::new_file_audio()
{
    // Déclaration
    int i=1;
  [/COLOR]  std::istringstream iss(m_liste_fichier_audio);
    std::string L_Fichier_audio;
    int L_nb_iter;   //

    //Code    
    if (this->m_cpt_tab>=this->m_nombre_fichier_audio) this->m_cpt_tab=0;
    
    L_nb_iter =  this->m_tab_playlist[this->m_cpt_tab];
    while ( std::getline( iss, L_Fichier_audio,';')[COLOR=#0000FF])
    { 
        if (i>=(L_nb_iter)){
            this->m_cpt_tab++;
            return L_Fichier_audio;
        }
        i++;
    }
    this->m_cpt_tab++;
    return L_Fichier_audio;
} 

// FUNCTION DE CALLBACK SPECIFIQUE BASS
//-------------------------------------
void CALLBACK Play_list::SyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
    {
        Play_list *self=(Play_list*)user;

        HSTREAM l_next_stream=0;
        BOOL l_return;
 
        std::string l_fic_audio = self->new_file_audio();

        l_next_stream = BASS_StreamCreateFile(false,l_fic_audio.c_str(),0,0,BASS_STREAM_DECODE|BASS_SAMPLE_FLOAT);
        l_return = BASS_Mixer_StreamAddChannel(self->m_mixer, l_next_stream, BASS_STREAM_AUTOFREE|BASS_MIXER_NORAMPIN);
        l_return = BASS_ChannelSetPosition(self->m_mixer,0,BASS_POS_BYTE);
    }

WD_BASS_PLAYLIST* Play_list::Creer()
//void Play_list::Creer(DWORD P_HDMixer, DWORD P_Nb_File_audio, const char *P_PlayList, DWORD P_len_char, BOOL P_Lect_alea)
// Paramètres à passer :
//---------------------
//  P_HDMixer est le steam mixer créé pour lire la playlist
//    P_Flags paramètres pour (voir doc bass)
//  P_Param paramètres pour (voir doc bass)
//  P_Nb_File_audio est le nombre de morceaux (fichiers audio) contenu dans la playlist
//  *P_PlayList est le pointeur sur P_PlayList qui est la chaine qui contient la liste des fichiers son séparés par un ;
//  P_len_char est la longuer de P_PlayList en nombre d'octets
//  P_Lect_alea est l'information de lecture aléatoire de la playlist True=1=Lecture aléatoire / False=0=Lecture séquentielle
// Valeur de retour :
//-------------------
//  Hstream est le N° Stream créé pour la lecture des fichiers audio
{

    m_liste_fichier_audio = m_PlayList;
    m_tab_playlist=init_tableau(1,m_nombre_fichier_audio);

    // On mélange si lecture aléatoire demandée
    //-----------------------------------------
    //m_lect_alea = false;
    if (this->m_lect_alea) this->melanger(this->m_tab_playlist,this->m_nombre_fichier_audio-1);

    std::string First_Fic_Audio = this->new_file_audio();

    this->m_mixer = BASS_Mixer_StreamCreate(44100,2,BASS_MIXER_END);
            
    BASS_ChannelSetSync(this->m_mixer,BASS_SYNC_END|BASS_SYNC_MIXTIME,0,this->SyncProc,this);
    
    this->m_source = BASS_StreamCreateFile(false,First_Fic_Audio.c_str(),0,0,BASS_STREAM_DECODE|BASS_SAMPLE_FLOAT);  //1st file open    
    BASS_Mixer_StreamAddChannel(m_mixer,this->m_source,BASS_STREAM_AUTOFREE);

    this->m_str_playlist.G_Mixer = this->m_mixer;
    this->m_str_playlist.G_Source = this->m_source;
    Play_list *const lc_Objet = this;
    this->m_str_playlist.G_Objet = static_cast<HANDLE>(lc_Objet);

    return &this->m_str_playlist;
}


extern "C" __declspec(dllexport) WD_BASS_PLAYLIST* SynchroPlaylist_Obj(const char *P_PlayList, DWORD P_Nb_File_audio, BOOL P_Lect_alea)
{
    Play_list * Playlist_ids;
    Playlist_ids = new Play_list(P_PlayList, P_Nb_File_audio,P_Lect_alea);    
    return Playlist_ids->Creer();
}

extern "C" __declspec(dllexport) bool DeletePlaylist_Obj(Play_list *const id_objet)
{
    delete id_objet;
    return true;
}