by yu0627 » 2006年11月18日(土) 16:42
現在、ActiveBasic上でOggVorbisをデコードするプログラムを作っているのですが、どうもうまくいきません。下は問題のコードです。
[ここをクリックすると内容が表示されます] [ここをクリックすると非表示にします]コード: 全て選択
'===========================================================
'
' Ogg Vorbis デコード テスト
'
'===========================================================
#include <vorbis/vorbisfile.sbp>
#include <api_mmsysPro4.sbp>
#include "fopen.sbp"
#N88BASIC
'WAVEFILEHEADER構造体
Type WAVEFILEHEADER
cRIFF[4] As Char
iSizeRIFF As Long
cType[4] As Char
cFmt[4] As Char
iSizeFmt As Char
WaveFmt As WAVEFORMATEX
cData[4] As Char
iSizeData As Long
End Type
'OggVorbisからコールバックを受けファイルの内容を読み出す関数
Function ovCB_read(ptr As *VoidPtr, size As DWord, nmemb As DWord, datasource As VoidPtr) As DWord
ovCB_read=fread(ptr, size, nmemb, datasource As *FILE)
End Function
'OggVorbisからコールバックを受けファイルを閉じる関数
Function ovCB_close(datasource As VoidPtr) As Long
ovCB_close=fclose(datasource As *FILE)
End Function
'OggVorbisからコールバックを受けファイルポインタを移動する関数
Function ovCB_seek(datasource As VoidPtr, offset As ogg_int64_t, whence As Long) As Long
ovCB_seek=fseek(datasource As *FILE, offset As Long, whence)
End Function
'OggVorbisからコールバックを受け現在のファイルポインタの位置を返す関数
Function ovCB_tell(datasource As VoidPtr) As Long
ovCB_tell=ftell(datasource As *FILE)
End Function
'==========================
' ここから本プログラム
'==========================
'各種ソフト情報を表示
Print "Ogg Vorbis file decode test in AB"
Print "======================================================"
Print Ex"Operation\t\t\tResult"
Print "------------------------------------------------------"
Dim lpstrDecodeFileName[MAX_PATH] As Byte 'デコードするファイル
'デコードするファイルを設定
lstrcpy(lpstrDecodeFileName, OggVorbisファイルへのパス)
Dim fp As *FILE
fp=fopen(lpstrDecodeFileName, "rb")
If fp=NULL Then
Print Ex"Open decode file\t\tFalse"
goto *Exit
Else
Print Ex"Open decode file\t\tSuccess"
End If
'OggVorbisのファイル情報を取得
Dim vf As *OggVorbis_File
Dim ovCB As ov_callbacks
ovCB.read_func = AddressOf(ovCB_read)
ovCB.close_func = AddressOf(ovCB_close)
ovCB.seek_func = AddressOf(ovCB_seek)
ovCB.tell_func = AddressOf(ovCB_tell)
If ov_open_callbacks(fp, vf, NULL, 0, ovCB) < 0 Then
Print Ex"Acquire file information of OggVorbis\tFalse"
goto *Exit
Else
Print Ex"Acquire file information of OggVorbis\tSuccess"
End If
fclose(fp)
'End of program
*Exit
このコードでデバッグするとov_open_callbacksの部分で止まってしまいます。
OggVorbisSDKの宣言はNoWestさんが配布しているab4apiのものです。
「api_mmsysPro4.sbp」はNoWestさんが以前配布されていたものです。
また、fopen.sbpの中身は以下のようになっています。
コード: 全て選択
Declare Function fopen CDECL Lib "crtdll" (__path As *Byte, __mode As *Byte) As *FILE
Declare Function fclose CDECL Lib "crtdll" (__stream As *FILE) As Long
Declare Function fflush CDECL Lib "crtdll" (__stream As *FILE) As Long
Declare Function fprintf CDECL Lib "crtdll" (__stream As *FILE, __format As *Char, ...) As Long
Declare Function fscanf CDECL Lib "crtdll" (__stream As *FILE, __format As *Char, ...) As Long
Declare Function feof CDECL Lib "crtdll" (__fp As *FILE) As Long
Declare Function ftell CDECL Lib "crtdll" (__fp As *FILE) As Long
Declare Function fread CDECL Lib "crtdll" (__ptr As VoidPtr, __size As DWord, __n As DWord, __stream As *FILE) As DWord
Declare Function fseek CDECL Lib "crtdll" (__stream As *FILE, __offset As Long, __whence As Long) As Long
なお、ovCB構造体にアドレスを指定している各関数はCからの移植です。
下はもともとのCのものです。
コード: 全て選択
size_t ovCB_read(void *buf, unsigned int a, unsigned int b, void * fp) {
return fread(buf, a, b, (FILE *)fp);
}
int ovCB_close(void * fp) {
return fclose((FILE *)fp);
}
int ovCB_seek(void *fp, __int64 a, int b) {
return fseek((FILE *)fp, (long)a, b);
}
long ovCB_tell(void *fp) {
return ftell((FILE *)fp);
}
色々と試してみたのですが全く解決しないので、投稿しました。
どこがいけないのでしょうか。
現在、ActiveBasic上でOggVorbisをデコードするプログラムを作っているのですが、どうもうまくいきません。下は問題のコードです。
[hide][code]'===========================================================
'
' Ogg Vorbis デコード テスト
'
'===========================================================
#include <vorbis/vorbisfile.sbp>
#include <api_mmsysPro4.sbp>
#include "fopen.sbp"
#N88BASIC
'WAVEFILEHEADER構造体
Type WAVEFILEHEADER
cRIFF[4] As Char
iSizeRIFF As Long
cType[4] As Char
cFmt[4] As Char
iSizeFmt As Char
WaveFmt As WAVEFORMATEX
cData[4] As Char
iSizeData As Long
End Type
'OggVorbisからコールバックを受けファイルの内容を読み出す関数
Function ovCB_read(ptr As *VoidPtr, size As DWord, nmemb As DWord, datasource As VoidPtr) As DWord
ovCB_read=fread(ptr, size, nmemb, datasource As *FILE)
End Function
'OggVorbisからコールバックを受けファイルを閉じる関数
Function ovCB_close(datasource As VoidPtr) As Long
ovCB_close=fclose(datasource As *FILE)
End Function
'OggVorbisからコールバックを受けファイルポインタを移動する関数
Function ovCB_seek(datasource As VoidPtr, offset As ogg_int64_t, whence As Long) As Long
ovCB_seek=fseek(datasource As *FILE, offset As Long, whence)
End Function
'OggVorbisからコールバックを受け現在のファイルポインタの位置を返す関数
Function ovCB_tell(datasource As VoidPtr) As Long
ovCB_tell=ftell(datasource As *FILE)
End Function
'==========================
' ここから本プログラム
'==========================
'各種ソフト情報を表示
Print "Ogg Vorbis file decode test in AB"
Print "======================================================"
Print Ex"Operation\t\t\tResult"
Print "------------------------------------------------------"
Dim lpstrDecodeFileName[MAX_PATH] As Byte 'デコードするファイル
'デコードするファイルを設定
lstrcpy(lpstrDecodeFileName, OggVorbisファイルへのパス)
Dim fp As *FILE
fp=fopen(lpstrDecodeFileName, "rb")
If fp=NULL Then
Print Ex"Open decode file\t\tFalse"
goto *Exit
Else
Print Ex"Open decode file\t\tSuccess"
End If
'OggVorbisのファイル情報を取得
Dim vf As *OggVorbis_File
Dim ovCB As ov_callbacks
ovCB.read_func = AddressOf(ovCB_read)
ovCB.close_func = AddressOf(ovCB_close)
ovCB.seek_func = AddressOf(ovCB_seek)
ovCB.tell_func = AddressOf(ovCB_tell)
If ov_open_callbacks(fp, vf, NULL, 0, ovCB) < 0 Then
Print Ex"Acquire file information of OggVorbis\tFalse"
goto *Exit
Else
Print Ex"Acquire file information of OggVorbis\tSuccess"
End If
fclose(fp)
'End of program
*Exit[/code][/hide]
このコードでデバッグするとov_open_callbacksの部分で止まってしまいます。
OggVorbisSDKの宣言はNoWestさんが配布しているab4apiのものです。
「api_mmsysPro4.sbp」はNoWestさんが以前配布されていたものです。
また、fopen.sbpの中身は以下のようになっています。[code]Declare Function fopen CDECL Lib "crtdll" (__path As *Byte, __mode As *Byte) As *FILE
Declare Function fclose CDECL Lib "crtdll" (__stream As *FILE) As Long
Declare Function fflush CDECL Lib "crtdll" (__stream As *FILE) As Long
Declare Function fprintf CDECL Lib "crtdll" (__stream As *FILE, __format As *Char, ...) As Long
Declare Function fscanf CDECL Lib "crtdll" (__stream As *FILE, __format As *Char, ...) As Long
Declare Function feof CDECL Lib "crtdll" (__fp As *FILE) As Long
Declare Function ftell CDECL Lib "crtdll" (__fp As *FILE) As Long
Declare Function fread CDECL Lib "crtdll" (__ptr As VoidPtr, __size As DWord, __n As DWord, __stream As *FILE) As DWord
Declare Function fseek CDECL Lib "crtdll" (__stream As *FILE, __offset As Long, __whence As Long) As Long[/code]
なお、ovCB構造体にアドレスを指定している各関数はCからの移植です。
下はもともとのCのものです。[code]size_t ovCB_read(void *buf, unsigned int a, unsigned int b, void * fp) {
return fread(buf, a, b, (FILE *)fp);
}
int ovCB_close(void * fp) {
return fclose((FILE *)fp);
}
int ovCB_seek(void *fp, __int64 a, int b) {
return fseek((FILE *)fp, (long)a, b);
}
long ovCB_tell(void *fp) {
return ftell((FILE *)fp);
}[/code]
色々と試してみたのですが全く解決しないので、投稿しました。
どこがいけないのでしょうか。